/* eslint valid-jsdoc: "off" */
const { join } = require('path');
const { env } = require('process');
/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/

  const config = { ...exports };
  config.middleware = [
    'rootMiddleware', 'status'
  ];
  config.static = {
    prefix: '/', // 静态文件访问前缀
    // dir: join(appInfo.baseDir, 'app/public'), // 静态文件目录
    defaultFile: 'index.html',

  };

  config.view = {
    defaultViewEngine: 'ejs',
    // root: join(appInfo.baseDir, 'app/view'), // 静态文件目录
    // root: [
    //   path.join(appInfo.baseDir, 'app/view'),
    //   path.join(appInfo.baseDir, 'app/public'),
    // ].join(','),
    mapping: {
      // 模板文件以html结尾
      '.html': 'ejs',
    },
  };

  // config.assets = {

  //   devServer: {
  //     autoPort: true,
  //     // command: 'roadhog dev',
  //     //  port: 443,
  //   },
  // };
  // 配置微信认证
  config.passportWechat = {
    key: 'wx3fc592efe61d7406',
    clientID: 'wx3fc592efe61d7406',
    clientSecret: 'c2cc7dc8e997ccf1957d8a0359271391',
    secret: 'c2cc7dc8e997ccf1957d8a0359271391',
    callbackURL: 'http://276i68d708.zicp.vip/callback',
    scope: 'snsapi_userinfo',
    state: 'egg',
  };
  // use for cookie sign key, shoulsd change to your own and keep security
  config.keys = appInfo.name + '_1730618593373_2298';
  config.jsonp = {
    csrf: false,
  };
  config.security = {
    csrf: {
      enable: false,
      cookieName: 'egg', // Cookie 中的字段名，默认为 csrfToken
      sessionName: 'egg', // Session 中的字段名，默认为 csrfToken
    },
  };
  config.cluster = {
    listen: {
      host: '0.0.0.0',
    },
    // https证书配置
    https: {
      key: join(__dirname, 'key.key'),
      cert: join(__dirname, 'cert.pem'),
    },
  };

  // add your middleware config here

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  // console.log('config', config)
  return {
    ...config,
    ...userConfig,
  };
};
